package com.alibaba.ecool.service.impl;

import java.util.List;
import java.util.Random;

import com.alibaba.ecool.bean.Question;
import com.alibaba.ecool.dao.MultichoiceDAO;
import com.alibaba.ecool.service.MultipleChoiceEditService;

public class MultipleChoiceEditServiceImpl implements MultipleChoiceEditService{
	int subjectCount,maxDiff,minDiff;
	MultichoiceDAO multichoiceDAO;
	Question question;
	String testsort;
	
	public MultichoiceDAO getMultichoiceDAO() {
		return multichoiceDAO;
	}

	public void setMultichoiceDAO(MultichoiceDAO multichoiceDAO) {
		this.multichoiceDAO = multichoiceDAO;
	}
	
	public Question getQuestion() {
		return question;
	}

	public void setQuestion(Question question) {
		this.question = question;
	}
	public Question getMultipleChoice(String testsort) {
		this.testsort=testsort;
		if("CEE".equals(testsort.trim())){
			question.setSubjectCount(20);
			question.setMaxDif(25);
			question.setMinDif(10);
			
		}
		else
			if("CET-4".equals(testsort.trim()))
			{
				question.setSubjectCount(20);
				question.setMaxDif(30);
				question.setMinDif(15);
			}
			else
				if("CET-6".equals(testsort.trim()))
				{
					question.setSubjectCount(20);
					question.setMaxDif(35);
					question.setMinDif(20);
				}
		else
			if("KaoYan".equals(testsort.trim()))
			{
				question.setSubjectCount(20);
				question.setMaxDif(40);
				question.setMinDif(25);
			}
		else 			
		{
			question.setSubjectCount(0);
			question.setMaxDif(0);
			question.setMinDif(0);
		}
		
		return question;
	}
		
	
	public int getMultipleChoiceCount(Question question) {
		question=this.question;
		subjectCount=multichoiceDAO.getCountByDifficult(question);

		return subjectCount;
	}
	
	public List randomMultipleChoice(String  testsort) {
		this.testsort=testsort;
		question=getMultipleChoice(testsort);
		subjectCount=getMultipleChoiceCount(question);
		Random r = new Random();
		question.setRow((int) (Math.random()*(subjectCount-question.getSubjectCount())));

		List list=multichoiceDAO.getMultichoiceByRow(question);
		
		return list;
		
	}



/*
	public int getMultichoiceDAO(String testsort, float esayRatio,
			float middleRatio, float hardRatio) {
		// TODO Auto-generated method stub
		return 0;
	}*/

	@Override
	public int getMultipleChoiceCount(String testsort) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public List randomMultipleChoice(int subjectCount, int maxdiff, int mindiff) {
		// TODO Auto-generated method stub
		return null;
	}

	


}
